package demo;
class Animal {
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public void eat() {
        System.out.println(name + "正在吃饭...");
    }
}
class Dog extends Animal {
    public Dog (String name,int age) {
        super(name,age);
    }
    public void eat () {
        System.out.println(name + "正在吃狗粮...");
    }
    public void bark() {
        System.out.println(name + "正在汪汪叫...");
    }
}

class Bird extends Animal {
    public Bird (String name,int age) {
        super(name,age);
    }
    public void eat () {
        System.out.println(name + "正在吃鸟粮...");
    }
    public void fly() {
        System.out.println(name + "正在飞...");
    }
}

public class Test {
    public static void main(String[] args) {
        Dog animal1 = new Dog("旺财",2);
        Animal animal2 = new Bird("小花",1);
        /*func(dog);
        func(cat);*/
        //Dog dog = (Dog)animal1;
        //dog.bark();
        //Bird bird = (Bird) animal1;
        //bird.fly();

    }
    public static void func(Animal a) {
        a.eat();
    }
}
